home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Floppyshop 2
/
Floppyshop - 2.zip
/
Floppyshop - 2.iso
/
art&graf.ix
/
art-4543
/
mvg
/
mod_code
/
meth2.s
< prev
next >
Wrap
Text File
|
1987-04-21
|
17KB
|
629 lines
; Equates file for Module METHOD # 2
; FUNCTION CALLS from MVG v1.3 only!
; output gridbig.prg
***************************************************************************
* *
* ------------------------ First, some legalese ------------------------- *
* *
* Source code Copyright (C) 1989,90 W. David Parks. All rights reserved. *
* No part of this SOURCE CODE may be reproduced, transmitted, transcribed *
* stored in a retrieval system, or translated in any form or by any means *
* without the prior written permission of the author, W.D.Parks *
* *
* *
* We make no representations or warranties with respect to the contents *
* of this document and specifically disclaim any implied warranties or *
* merchantability, or fitness for any particular purpose. *
* *
* ----------------------------------------------------------------------- *
* *
* Written permission is granted to registered owners to use *
* any or all of this source code in their own modules for *
* private use. Please contact Dr. Bobware for details for *
* any commercial use. *
* *
* *
* *
***************************************************************************
* last changed: 04/19/90
* this source code is intended for HiSoft's Assembler, GENST2.
* other assemblers can be used with little modification.
* the biggest requirement is it's MACRO capability.
* after having Macros, I find it quite hard to live without them.
* although I'm sure I remember a time when I did...
* or was that just a nightmare I once had... I dunno...
;source code is copyright w.david parks, all rights reserved
;
;
;MOD_EQU: Standard equates for Module setup
*****************************************************************************
************************** MACROS for EASY Functions ***********************
*****************************************************************************
******************************* Call a routine that's inside MVG.
******************************* Use inline.
******************************* sample: callmvg ANYKEY
callmvg macro function_number
push.l #\1
move.l mvg_func,a6
jsr (a6)
addq.l #4,sp
endm
******************************* Call a routine that's inside MVG.
******************************* Use for stand-alone routine in MODULE
******************************* (places an RTS at the end... that's all)
callmvgr macro function_number
callmvg \1
rts
endm
******************************* Lazy_Typer's MOVE.? _whatever_,-(sp)
*******************************
******************************* ie Push something on the stack
*******************************
******************************* HISOFT option "\0" automatically
******************************* appends any entered size, default=W
******************************* sample: PUSH.L #4 = move.l #4,-(sp)
push macro
move.\0 \1,-(sp)
endm
******************************* Lazy_Typer's MOVE.? (sp)+,_whatever_
*******************************
******************************* ie Pop something off the stack
*******************************
******************************* HISOFT option "\0" automatically
******************************* appends any entered size, default=W
******************************* sample: POP.L D7 = move.l (sp)+,D7
pop macro
move.\0 (sp)+,\1
endm
******************************* Lazy_Typer's MOVEM.L A0-A6/D0-D7,-(sp)
*******************************
******************************* ie push everything on the stack!
pha macro
movem.l a0-a6/d0-d7,-(sp)
endm
******************************* Lazy_Typer's MOVEM.L (sp)+,A0-A6/D0-D7
*******************************
******************************* ie pop everything back off the stack!
pla macro
movem.l (sp)+,a0-a6/d0-d7
endm
;--------------------------------------------------------------------
; MVG Packet #2 equates
;--------------------------------------------------------------------
;
;equates used as Function Number for calling MVG via "callmvg"
;
;!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
;!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
;
; REMEMBER! MVG 1.2 owners CANNOT use this method of packet access
;
; !!!!!!!!!!SO BE SURE TO CHECK THE VERSION NUMBER!!!!!!!!!
;
;!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
;!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
GETVARS equ 0 ;A1--> Varlist
GETBUFS equ 1 ;A0->Main, D0=W,H D1=MAXLEN, A1->CB
GETCBUF equ 2 ;A0->CB
C_VID2CB equ 3 ;COPY video to CB
C_VID2MAIN equ 4 ;copy video to main (0-3)
C_CB2MAIN equ 5 ;copy CB to main (0-3)
C_MAIN2CB equ 6 ;copy main (0-3) to CB
ANYKEY equ 8 ;wait for key, returnds D0.L
WHEREM equ 9
SETXY equ 10
GDISPLAY equ 11
DISPLAY_CB equ 12
TOPTITLE equ 13
HI_CHAR equ 14
HI_STRING equ 15
PHEX1 equ 16
HEXIT equ 17
HEXITL equ 18
BDEC2 equ 19
BDEC3 equ 20
BDEC4 equ 21
GET_MISC equ 22
ASKMISC equ 23
COPYTOZ equ 26
APPENDTO equ 27
ADDEXT equ 28
SETMOUSEXY equ 31
SETSIZE equ 35
ATOG_NRM equ 36
ATOG_XOR equ 37
MAKEBOX equ 38
MAKEXBOX equ 39
SET_LINE equ 40
MAKELINE equ 41
RECTANG_Q equ 42
EALERT equ 45
;------------------------- equates for index into VAR_LIST
V_WID equ 0
V_HGT equ 4
V_PIX equ 8
V_REZ equ 12
V_CBF equ 24
V_INTI equ 32
V_ADRI equ 36
V_INTO equ 40
V_ADRO equ 44
V_MDIR equ 48
V_MFIL equ 52
V_FILN equ 56
V_RFIL equ 60
*******************************************************************
;=================================================================
; MOD_INI: Initialization routines for Module setup
;=================================================================
;
; the program proper
;
;
section text
PRG_INIT:
bra begin
siggy
dc.b 'MVG Module: xxxxxx xxxxxx xxx',0 ;30 bytes
even
begin
move.l 4(a7),a3 base page
move.l a3,basepage save it for later
move.l #ustack,a7 use local stack
move.l $c(a3),d0 text len
add.l $14(a3),d0 data len
add.l $1c(a3),d0 BSS len
add.l #$100,d0 basepage
move.l d0,-(sp)
move.l a3,-(sp)
clr.w -(sp)
move.w #$4a,-(sp)
trap #1 shrink memory
lea 12(sp),sp
;=================================================================
; ---------------- start test for MVG signature ----------------
;=================================================================
move.b #$30,ernum start error text number at "0"
move.l $24(a3),a0 parent's basepage adrs
move.l a0,parent save temp
add.l #$80,a0 point A0--> parent's command_line
move.l (a0)+,a6
move.l a6,mvg_packet adrs of packet
move.l (a0)+,d0
move.l (a0)+,d1
cmp.l MVG_SIG,d0 ;0,"MVG"
bne badbye ;MVG is not the caller... no packet
move.b #$31,ernum ;up the ernum to "1"
cmp.l MVG_VER,d1 ;match version number string "1.30"
blt badver ;MVG is older version than required.
bgt .2a ;additional checking can be made on
;word following version number in
;parent's basepage, if necessary.
move.b (a0),d0 ;fetch character (version extension)
; clr.w oldver
cmp.b min_ver,d0 ;1.20 "h" is earliest version usable
blt badver
; bgt .2a
; move.w #1,oldver
.2a
cmp.w MVG_MAX,d1
bgt badver
*****************************************************************************
************* Set up generic variables and other packet items **************
read_packet:
move.l a6,a5
sub.l #4,a5 ;(Packet - 4) ---> Function dispatcher in MVG
move.l (a5),mvg_func
sub.l #4,a5
move.l (a5),mvg_vars ;(Packet - 8) ---> Var_List
lea packet,a1
move.l a6,a0
move.l #4,d0
.0
move.l (a0)+,(a1)+ ;copy first 5 items from PACKET
dbf d0,.0 ;easy way to get adrs of buffers & misc
move.l _wid,a0 ;read width from MVG and store locally
move.w (a0),wid
move.l _hgt,a0 ;read height from MVG and store locally
move.w (a0),hgt
jmp Main_Action ; JUMP TO USER'S CODE
*************************************************************************
;========================================================================
;============= Some subroutines with labels for local calling ==========
anykey:
push.l #ANYKEY
move.l mvg_func,a6
jsr (a6)
addq.l #4,sp
rts
bell
move.w #7,d0
hi_char:
push.l #HI_CHAR
move.l mvg_func,a6
jsr (a6)
addq.l #4,sp
rts
prin:
hi_string:
push.l #HI_STRING
move.l mvg_func,a6
jsr (a6)
addq.l #4,sp
rts
;-------------------------- Copy a string A0--->A1
copytoz:
push.l #COPYTOZ
move.l mvg_func,a6
jsr (a6)
addq.l #4,sp
rts
;------------------------- Poll the mouse position and button status
;-------------------------- Store the position in local variable
wherem:
callmvg WHEREM
move.l d1,mouse_xy
rts
mouse_xy
mouse_x dc.w 0
mouse_y dc.w 0
;---------------------------------- if you need these routines
;---------------------------------- then this'll make 'em
;---------------------------------- easily accessible as local labels
;---------------------------------- rather than using "callmvg" each
;---------------------------------- time you access
addext callmvgr ADDEXT
appendto callmvgr APPENDTO
bdec2 callmvgr BDEC2
bdec3 callmvgr BDEC3
bdec4 callmvgr BDEC4
phex1 callmvgr PHEX1
hexit callmvgr HEXIT
hexitl callmvgr HEXITL
drawbox callmvgr MAKEBOX
drawxbox callmvgr MAKEXBOX
askmisc callmvgr ASKMISC
setsize callmvgr SETSIZE
alerter callmvgr EALERT
setmousexy callmvgr SETMOUSEXY
atognrm callmvgr ATOG_NRM
atogxor callmvgr ATOG_XOR
rectang_q callmvgr RECTANG_Q
setline callmvgr SET_LINE
makeline callmvgr MAKELINE
toptitle callmvgr TOPTITLE
gdisplay callmvgr GDISPLAY
************************************************************************
************************************************************************
;--------------------------------------------------------------------
;Routines for exiting if not run as a module or from a version of MVG
;that is too early............
;
;!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
;
; This method of Packet access is only available in
; MVG version 1.3...... CHECK FOR THE PROPER VERSION!
;
;!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
************************************************************************
************************************************************************
badver
lea ermsg2,a0 ;print error msg
bsr sysprin
lea MVG_VER,a0
bsr sysprin
bra byex ;exit back to... caller (MVG)
badbye
lea ermsg,a0 ;No Packet Provided (MVG not parent of module)
bsr sysprin
byex
push.w #7 ;wait for keypress via GEMDOS
trap #1
addq.l #2,sp
gbye:
gbyeoops:
push.w #2 ;at this time, MVG does not inquire
push.w #$4c ;for an error return number. This
trap #1 ; #2 is arbitrarily selected here.
sysprin ;print a string using GEMDOS
push.l a0
push.w #9
trap #1
addq.l #6,sp
rts
good_bye ;exit without error code
push.w #0
push.w #$4c
trap #1
ermsg dc.b 27,'Y',32,32,27,'K Err# '
ernum dc.b '0 Cannot Find MVG Packet',7,0
even
ermsg2 dc.b 27,'Y',32,32,27,'K Requires MVG version # ',0
even
MVG dc.w 0,0
MODULE_ID dc.w 0,0
MVG_SIG dc.b 0,'MVG'
MVG_VER dc.b '1.30' ;minimum version MVG to use this module
MVG_SUBVER dc.b ' ',0 ;a sub version is always 1-byte long.
basepage dc.l 0
parent dc.l 0
mvg_vars dc.l 0
mvg_func dc.l 0
mvg_packet dc.l 0
min_ver dc.b 0,0 ;SET REQUIRED MINIMUM CHAR HERE
MVG_MAX dc.b '39',0,0 ;required MAX
packet:
bgraph dc.l 0 ;pointer to main image buffer
buflen dc.l 0 ;length of main image buffer
_wid dc.l 0 ;pointer to MVG's var: WID
_hgt dc.l 0 ;pointer to MVG's var: HGT
clipboard dc.l 0 ;pointer to clipboard buffer
wid dc.w 0 ;local label, loaded with image width (via MVG's WID)
hgt dc.w 0 ;local label, loaded with image height (via MVG's HGT)
cb_flag dc.w 0
;oldver dc.w 0
***************************************************************************
***************************************************************************
***************************************************************************
***************************************************************************
Main_Action
; Your code goes here........ exit with P_TERM
* #############################################################*
* ######### SAMPLE CODE: COPY VIDEO TO CLIPBOARD ##########*
* ######### ##########*
* ######### Three different samples, all the same ##########*
* #############################################################*
;---------------------------- standard 68000 syntax
; move.l #C_V2CB,-(sp) ;push the function number on the stack
; movea.l mvg_func,a6 ;get func_dispatcher into address register
; jsr (a6) ;JSR indirect via register
; addq.l #4,(sp) ;restore stack
; bra go_byebye ;exit via p_term
;
;---------------------------- same code, using push macro
; push.l #C_V2CB
; move.l mvg_func,a6
; jsr (a6)
; addq.l #4,sp
; bra go_byebye
;
;--------------------------- same, again, using "callmvg" macro
; callmvg #C_V2CB
; bra go_byebye
;
; nop
;go_byebye:
; push.w #0 ;return error code of zero: no-error
; push.w #$4c ;GEMDOS p_term (exit back to whatever caller)
; trap #1
;
* #############################################################*
* ######### ##########*
* ######### SAMPLE CODE: WRITE A GRID to IMAGE ##########*
* ######### ##########*
* #############################################################*
bsr gdisplay ;display the current image
lea first_lert,a0
moveq #1,d0
bsr alerter
cmp.w #2,d0
beq goombye
grid_rows:
move.l bgraph,a3
clr.l d7
clr.l d6
clr.l d5
move.w hgt,d7
move.w wid,d6
move.l d6,d5
lsl.l #4,d5 ;every 16 rows
.0
move.b #$ff,d0
move.l a3,a2
move.l d6,d1
subq.w #1,d1
.1
move.b d0,(a2)+
dbf d1,.1
add.l d5,a3
sub.w #8,d7
bpl .0
grid_columns:
move.l bgraph,a3
clr.l d7
clr.l d6
clr.l d5
move.w hgt,d7
move.w wid,d6
move.l d6,d5
asr.w #1,d5
subq.w #1,d5
.0
move.b #$80,d0
move.l a3,a2
move.l d7,d1
subq.w #1,d1
.1
move.b (a2),d2
or.b d0,d2
move.b d2,(a2)
add.l d6,a2
dbf d1,.1
addq.l #2,a3
dbf d5,.0
; bsr anykey
bra goombye
nop
goombye
push.w #0
push.w #$4c P_TERM, this is the way we exit a module
trap #1 (but you knew that)
********************************************************************
********************************************************************
********************************************************************
section data
even
;for sample module
first_lert dc.b '[0]['
dc.b ' Draw a Grid on |'
dc.b ' the current |'
dc.b ' Image? ]'
dc.b '[Yes|No]'
even
***************************************************************************
***************************************************************************
***************************************************************************
***************************************************************************
section bss
even
ds.l 300
ustack ds.l 1
end